package com.bawei.yangzongcai___chenmei.SlindingMenu;

import android.app.DatePickerDialog;
import android.app.TimePickerDialog;
import android.os.Bundle;
import android.view.View;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;

import androidx.appcompat.app.AppCompatActivity;

import com.bawei.yangzongcai___chenmei.R;
import com.blankj.utilcode.util.ToastUtils;

import java.util.Calendar;

public class SlingMenuActivity7 extends AppCompatActivity {

    private TextView riqi;
    private TextView shijian;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_sling_menu7);
        initView();
        riqi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calendar calendar =Calendar.getInstance();
                new DatePickerDialog(SlingMenuActivity7.this, new DatePickerDialog.OnDateSetListener() {
                    @Override
                    public void onDateSet(DatePicker view, int year, int month, int dayOfMonth) {
                      riqi.setText(year+"年——"+month+"月——"+dayOfMonth+"日");
                    }
                },calendar.get(Calendar.YEAR) , calendar.get(Calendar.MONTH),calendar.get(Calendar.DAY_OF_MONTH)).show();
            }
        });

        shijian.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Calendar calendar =Calendar.getInstance();
               new TimePickerDialog(SlingMenuActivity7.this, new TimePickerDialog.OnTimeSetListener() {
                   @Override
                   public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
                       shijian.setText(hourOfDay+"时："+minute+"分");
                   }
               },calendar.get(Calendar.HOUR),calendar.get(Calendar.MINUTE),true).show();
            }
        });
    }

    private void initView() {
        riqi = findViewById(R.id.riqi);
        shijian = findViewById(R.id.shijian);
    }
}
